LINE Statement ---------------------------------------------------------------------------- Action Draws a line or box on the screen. Syntax LINE STEP ( x1!, y1!) - STEP ( x2!, y2!) , color& , B F , style% Remarks The coordinates ( x1!, y1!) and ( x2!, y2!) specify the end points of the line; note that the order in which these end points appear is unimportant, since a line from (10,20) to (120,130) is the same as a line from (120,130) to (10,20). The STEP option makes the specified coordinates relative to the most-recent point. For example, if the most-recent point referred to by the program were (10,10), then the following statement would draw a line from (10,10) to the point with an x coordinate equal to 10 + 10 and a y coordinate equal to 10 + 5, or (20,15). LINE -STEP (10,5) You may establish a new most-recent point by initializing the screen with the CLS and SCREEN statements. Using the PSET, PRESET, CIRCLE, and DRAW statements will also establish a new most-recent point. Variations of the STEP argument are shown below. For the following examples, assume that the last point plotted was (10,10). ----------------------------------------------------------------------------- ---------------------------------------------------------------------------- LINE -(50,50) Draws from (10,10) to (50,50). LINE -STEP(50,50) Draws from (10,10) to (60,60). LINE (25,25)-STEP(50,50) Draws from (25,25) to (75,75). LINE STEP(25,25)-STEP(50,50) Draws from (35,35) to (85,85). LINE STEP(25,25)-(50,50) Draws from (35,35) to (50,50). The argument color% is the number of the color in which the line is drawn. (If the B or BF option is used, the box is drawn in this color.) For information on valid colors, see the SCREEN statement. The B option draws a box with the points ( x1!, y1!) and ( x2!, y2!) specifying diagonally opposite corners. The BF option draws a filled box. This option is similar to the B option; BF also paints the interior of the box with the selected color. The argument style% is a 16-bit integer mask used to put pixels on the screen. Using style% is called "line styling." With line styling, LINE reads the bits in style% from left to right. If a bit is 0, then no point is plotted; if the bit is 1, a point is plotted. After plotting a point, LINE selects the next bit position in style%. Because a zero bit in style% does not change the point on the screen, you may want to draw a background line before using styling so you can have a known background. Style is used for normal lines and boxes, but has no effect on filled boxes. When coordinates specify a point that is not within the current viewport, the line segment to that point is drawn to the border of the viewport. For more information on the LINE statement, see Chapter 5, "Graphics" in the Programmer's Guide. See Also CIRCLE, PSET, SCREEN Statement Examples The following example uses LINE statements to display a series of screens with different line graphics. To run this program, your screen must be 320 pixels wide by 200 pixels high and support CGA screen mode. SCREEN 1' Set up the screen mode. LINE -(X2, Y2)' Draw a line (in the foreground color) ' from the most recent point to X2,Y2. DO. LOOP WHILE INKEY$ = "" CLS LINE(0, 0)-(319, 199)' Draw a diagonal line across the screen. DO. LOOP WHILE INKEY$ = "" CLS LINE(0, 100)-(319, 100)' Draw a horizontal line across the screen. DO. LOOP WHILE INKEY$ = "" CLS LINE(10, 10)-(20, 20), 2 ' Draw a line in color 2. DO. LOOP WHILE INKEY$ = "" CLS FOR X = 0 to 319' Draw an alternating pattern LINE(X, 0)-(X, 199), X AND 1' (line on-line off) on mono- NEXT' chrome display. DO. LOOP WHILE INKEY$ = "" CLS LINE (0, 0)-(100, 100),, B' Draw a box in the foreground color ' (note that the color is not included). DO. LOOP WHILE INKEY$ = "" CLS LINE STEP(0,0)-STEP(200,200),2,BF ' Draw a filled box in color ' 2 (coordinates are given as ' offsets with the STEP option). DO. LOOP WHILE INKEY$ = "" CLS LINE(0,0)-(160,100),3,,&HFF00' Draw a dashed line from the ' upper-left corner to the ' center of the screen in color 3.